<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="css/search.css"/>
  
    <title>laya搜索</title>
    

  
</head>
<style>
    
</style>
<body>
    <div class="search">
            <div class="r_eturn">
                    <label>
                        <img src="images/return.png">
                    </label>
                    <span>Return</span>
            </div>
            <input type="text" placeholder="搜索" autofocus>
            <p>Searh anything & hit enter</p>
    </div>
</body>
<script>
  
    /*动态改变根元素字体大小*/
    function recalc() {
        var clientWidth = document.documentElement.clientWidth;
        if(!clientWidth) return;
        document.documentElement.style.fontSize = 40 * (clientWidth / 1920) + 'px';
    }
    
    function initRecalc() {
        recalc();
        var resizeEvt = 'osrientationchange' in window ? 'orientationchange' : 'resize';
        if(!document.addEventListener) return;
        window.addEventListener(resizeEvt, recalc, false);
        document.addEventListener('DOMContentLoaded', recalc, false);
    }
    initRecalc();
    
     console.log("手机viewportWidth=",document.documentElement.clientWidth);
        //获取viewport宽
        var viewportWidth = document.documentElement.clientWidth;
        console.log(document.documentElement.style.fontSize);
    </script>
  
    
</html>